//package com.lb;
//
//import org.springframework.context.annotation.Lazy;
//import org.springframework.stereotype.Component;
//import org.springframework.web.socket.server.standard.ServerEndpointExporter;
//
//import javax.websocket.HandshakeResponse;
//import javax.websocket.server.HandshakeRequest;
//import javax.websocket.server.ServerEndpointConfig;
//import org.springframework.web.context.ConfigurableApplicationContext;
//import org.springframework.web.context.support.WebApplicationContextUtils;
//
//@Component
//@Lazy
//public class SpringConfigurator extends ServerEndpointConfig.Configurator {
//
//    @Override
//    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
//        // 获取 Spring 上下文
//        ConfigurableApplicationContext context = (ConfigurableApplicationContext)
//                WebApplicationContextUtils.getWebApplicationContext(request.getHttpServletRequest().getServletContext());
//        sec.getUserProperties().put(ConfigurableApplicationContext.class.getName(), context);
//    }
//}